package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.DjiAirportBoundaryPosition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.DjiAirport;
import com.ruoyi.system.service.IDjiAirportService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 大疆机场Controller
 * 
 * @author ruoyi
 * @date 2024-03-26
 */
@RestController
@RequestMapping("/airport")
public class DjiAirportController extends BaseController
{
    @Autowired
    private IDjiAirportService djiAirportService;

    /**
     * 查询大疆机场列表
     */
    @RequiresPermissions("system:airport:list")
    @GetMapping("/list")
    public TableDataInfo list(DjiAirport djiAirport)
    {
        startPage();

        
        List<DjiAirport> list = djiAirportService.selectDjiAirportList(djiAirport);
        return getDataTable(list);
    }


    /**
     * 查询大疆机场列表
     */
    @RequiresPermissions("system:airport:list")
    @GetMapping("/listAll")
    public AjaxResult listAll(DjiAirport djiAirport)
    {
        List<DjiAirport> list = djiAirportService.selectDjiAirportListAll(djiAirport);
        return AjaxResult.success(list);
    }

    /**
     * 导出大疆机场列表
     */
    @RequiresPermissions("system:airport:export")
    @Log(title = "大疆机场", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DjiAirport djiAirport)
    {
        List<DjiAirport> list = djiAirportService.selectDjiAirportList(djiAirport);
        ExcelUtil<DjiAirport> util = new ExcelUtil<DjiAirport>(DjiAirport.class);
        util.exportExcel(response, list, "大疆机场数据");
    }

    /**
     * 获取大疆机场详细信息
     */
    @RequiresPermissions("system:airport:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(djiAirportService.selectDjiAirportById(id));
    }

    /**
     * 新增大疆机场
     */
    @RequiresPermissions("system:airport:add")
    @Log(title = "大疆机场", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DjiAirport djiAirport)
    {
        return toAjax(djiAirportService.insertDjiAirport(djiAirport));
    }

    /**
     * 修改大疆机场
     */
    @RequiresPermissions("system:airport:edit")
    @Log(title = "大疆机场", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DjiAirport djiAirport)
    {
        return toAjax(djiAirportService.updateDjiAirport(djiAirport));
    }

    /**
     * 删除大疆机场
     */
    @RequiresPermissions("system:airport:remove")
    @Log(title = "大疆机场", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(djiAirportService.deleteDjiAirportByIds(ids));
    }

//    @RequiresPermissions("system:airport:remove")
    @Log(title = "大疆机场", businessType = BusinessType.DELETE)
    @PostMapping("/savePosition")
    public AjaxResult savePosition(@RequestBody DjiAirportBoundaryPosition boundaryPosition)
    {
        return toAjax(djiAirportService.savePosition(boundaryPosition));
    }


}
